package drds.global_transaction.api.rpc;

/**
 * 这个是用来测试的,不能删除,可以进行合理性推理
 */
public class Magic
{
	public static final int magic_half = -38;
	public static short magic = (short) 0xdada;

	public static short getShort(byte[] bytes)
	{
		return (short) (((bytes[1] << 8) | bytes[0] & 0xff));
	}

	public static void main(String[] args)
	{
		byte[] bytes = new byte[2];
		putShort(bytes, magic);
		System.out.println(getShort(bytes) == magic);

	}

	public static void putShort(byte[] bytes, short s)
	{
		bytes[1] = (byte) (s >> 8);
		bytes[0] = (byte) (s >> 0);
		System.out.println(bytes[0] == (byte) magic_half);
		System.out.println(bytes[1] == (byte) magic_half);
	}
}
